package com.ecnu.system.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.ecnu.common.core.domain.AjaxResult;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;

@Data
public class ProjectDTO {
    @ApiModelProperty(value = "活动id")
    private String id;

    @NotBlank(message = "活动名称不能为空")
    @ApiModelProperty(value = "活动名称")
    private String proName;

//    @NotBlank(message = "活动类型不能为空")
    @ApiModelProperty(value = "活动类型")
    private String proType;

    @ApiModelProperty(value = "简介/特色")
    private String title;

    @ApiModelProperty(value = "图片地址")
    private String url;

    @ApiModelProperty(value = "活动开始时间")
    @NotNull(message = "活动开始时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date startTime;

    @ApiModelProperty(value = "活动结束时间")
    @NotNull(message = "活动结束时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date endTime;

    @ApiModelProperty(value = "活动头图地址")
    private String banner;

    @ApiModelProperty(value = "报名状态（1是，0否）")
    private String registrationType = "0";

    @ApiModelProperty(value = "报名开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date registrationStartTime;

    @ApiModelProperty(value = "报名结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date registrationEndTime;

    @ApiModelProperty(value = "活动状态（1开启，0关闭）")
    private String status;

    @ApiModelProperty("作者名")
    private String author;

    @ApiModelProperty("通讯作者")
    @TableField("corresp_author")
    private String correspAuthor;

    @ApiModelProperty("通讯邮箱")
    @TableField("corresp_email")
    private String correspEmail;

    @ApiModelProperty(value = "主讲人/主办方/负责人")
    private List<UserDto> teacherList;

    @ApiModelProperty(value = "成员")
    private List<UserDto> userList;

    @ApiModelProperty(value = "主办方(课程，成长营）")
    private String chargePerson;

    @TableField("contractor")
//    @JsonIgnore
    private String contractor;

    @ApiModelProperty(value = "活动文件")
    private List<ProjectIndexFileDTO> informations;

    @NotBlank(message = "可见范围不能为空")
    @ApiModelProperty(value = "可见范围（1自己可见，2机构可见，3平台可见）")
    private String isRange;

    @AssertTrue(message = "报名开启时，报名时限不能为空")
    public boolean isRegistrationTimeValid() {
        if ("1".equals(registrationType)) {
            return registrationStartTime != null && registrationEndTime != null;
        }
        return true;
    }
}